package xyz.xmh.dao.recycle.impl;

import xyz.xmh.dao.recycle.ReactiveRecycleDao;
import xyz.xmh.dao.recycle.RecycleDao;

/**
 * 2021/10/26 23:55 星期二<br/>
 * 回收站实现类
 *
 * @author xuMingHai
 */
public class RecycleDaoImpl implements RecycleDao {

    private final ReactiveRecycleDao reactiveRecycleDao;

    public RecycleDaoImpl(ReactiveRecycleDao reactiveRecycleDao) {
        this.reactiveRecycleDao = reactiveRecycleDao;
    }

    @Override
    public boolean trash(String fileId) {
        return Boolean.TRUE.equals(reactiveRecycleDao.trash(fileId)
                .toBodilessEntity()
                .map(voidResponseEntity -> voidResponseEntity.getStatusCode().is2xxSuccessful())
                .block());
    }
}
